from Containers.Container import ContainerPool
import gc

class PsCommand:

  def __init__(self):
    self.pool = ContainerPool()

  def run(self):
    id_len = 0
    running_len = 0
    
    print()

    for cid in self.pool.containers.keys():
      id_len = max(id_len, len(cid))

    running_len = len('Running') 

    print('ID' + ' ' * (id_len - 2) + ' ' + 'Status')
    
    for cid, container in self.pool.containers.items():
      running = 'Running' if container.running else 'Stopped'
      print(cid + ' ' * (id_len - len(cid)) + ' ' + running)
      
    #print('Free memory:' + ' ' * (id_len - 12) + running_len * ' ' + str(gc.mem_free()))
    print()

PsCommand().run()